package com.example.facility.service.receivereturn;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.facility.controller.admin.receivereturn.vo.ReceiveReturnPageReqVO;
import com.example.facility.controller.admin.receivereturn.vo.ReceiveReturnRespVO;
import com.example.facility.dal.dataobject.receivereturn.ReceiveReturnDO;
import com.example.facility.dal.mysql.ReceiveReturnMapper;

import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;


/**
 * 领用归还管理 Service 实现类
 *
 * @author 贵州上禾
 */
@Service
@Validated
public class ReceiveReturnServiceImpl extends ServiceImpl<ReceiveReturnMapper, ReceiveReturnDO> implements ReceiveReturnService {

    @Resource
    private ReceiveReturnMapper returnMapper;

    @Override
    public void deleteReturn(Long id) {
        // 删除
        returnMapper.deleteById(id);
    }

    @Override
    public List<ReceiveReturnRespVO> selectReturnList(ReceiveReturnPageReqVO pageReqVO) {
        if (pageReqVO.getType() == null) {
            throw new RuntimeException("类型不能为空(1领用 2归还)!");
        }
        return returnMapper.selectReturnList(pageReqVO);
    }
}